<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Socket.IO 快速启动</title>
  </head>
  <body>
    <script src="https://cdn.socket.io/current/socket.io.min.js"></script>
    <script>
      // 连接到Socket.IO服务器
      var socket = io("http://localhost:8000");

      // 监听服务器的消息
      socket.on("connect", function () {
        console.log("连接成功");
        socket.emit("my event", { data: "我发送的数据" });
      });

      socket.on("message", function (data) {
        console.log("接收到消息:", data);
      });
    </script>
  </body>
</html>
